#include "stdio.h"
#include "TM1637.h"
#include "delay.h"
#include "usart.h"
#include "Time_Show.h"
#include "Key_Control.h"
#include "main.h"
#include "Time2.h"

extern uint8_t sec_flag;

int8_t mode;
int DEBUG_PRT=1;
int DEBUG_ERR=1;
int DEBUG_INF=0;

int main(void)
{
    NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
    /*串口打印初始化*/
    My_USART1_Init();
    printf("APP START\r\n");
    
    /*tm1637驱动初始化*/
    tm1637_Init();
    //ShowTest();
    
    /*按键初始化*/
    Key_Init();
    
    /*时间显示初始化*/
    TM1637_SetBrightness(level2);
    Time_Init(12,34);
    
    /*时基——定时器2初始化*/
    TIM_Init(10000-1,7200-1);/*用处1——1s计时*/
    mode = normal_mode;
    printf("[mode %d]\r\n", mode);

	while(1){
        /*采用TIM2*/
        if(sec_flag){
            sec_flag = 0;
            Time_Add_a_second();
        }

        if(modify_mode == mode){
            mode_modify();
            printf("[mode %d]\r\n", mode);
            TIM_Init(10000-1,7200-1);
        }
    }
    
}

